package com.legutech.gsyvideoplayer.gsy_video_player;

import android.content.Context;

import java.util.Map;

import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.common.MessageCodec;
import io.flutter.plugin.common.StandardMessageCodec;
import io.flutter.plugin.platform.PlatformView;
import io.flutter.plugin.platform.PlatformViewFactory;

public class GSYVideoPlayerViewFactory extends PlatformViewFactory {

    private BinaryMessenger messenger = null;

    /**
     * @param createArgsCodec the codec used to decode the args parameter of
     *                        {@link #create}.
     */
    public GSYVideoPlayerViewFactory(MessageCodec<Object> createArgsCodec) {
        super(createArgsCodec);
    }

    public GSYVideoPlayerViewFactory(BinaryMessenger messenger) {
        super(StandardMessageCodec.INSTANCE);
        this.messenger = messenger;
    }

    @Override
    public PlatformView create(Context context, int viewId, Object data) {
        Map<String, Object> params = (Map<String, Object>) data;
        String dataSource = params.get("dataSource").toString();
        String tag = params.get("tag").toString();
        String title = params.get("title").toString();
        return new GSYVideoPlayerView(context, dataSource, tag, title,
                messenger);
    }
}
